package com.wang.mandkey.adapter;

import java.util.ArrayList;

import com.wang.mandkey.R;

import android.content.Context;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ImageView;
import android.widget.TextView;

public class BoxAdapter extends BaseAdapter {

	private ArrayList<String> mArrayList;
	private Context mContext;

	public BoxAdapter(ArrayList<String> datas, Context context) {
		this.mArrayList = datas;
		this.mContext = context;
	}

	@Override
	public int getCount() {
		return mArrayList.size();
	}

	@Override
	public Object getItem(int position) {

		return position;
	}

	@Override
	public long getItemId(int position) {
		return position;
	}

	@Override
	public View getView(int position, View convertView, ViewGroup parent) {

		ViewHolder vl;
		if (null == convertView) {
			vl = new ViewHolder();
			convertView = View.inflate(mContext, R.layout.box_item, null);
			vl.imgv = (ImageView) convertView.findViewById(R.id.imageViewIcon);
			vl.tv = (TextView) convertView.findViewById(R.id.txtViewNotify);
			convertView.setTag(vl);
		} else {
			vl = (ViewHolder) convertView.getTag();
		}
		vl.tv.setText(mArrayList.get(position));
		
		return convertView;
	}

	class ViewHolder {
		ImageView imgv;
		TextView tv;
	}

}
